%% -----------------------------------------------------------------------------
%% 发布用预留，功能未实现
{relx,
  [ {release, {catsvr, "0.1.0"}, [catsvr]}
  , {extended_start_script, true}
  , {dev_mode, false}
  , {include_erts, false}
  , {system_libs, false}
  , {include_src, false}
  , {sys_config, "./config/sys.config"}
  , {vm_args, "./config/vm.args"}
  ]
}.


%% -----------------------------------------------------------------------------
{erl_opts, 
  [ debug_info
  , {i, "./_build/default/plugins/gpb/include"}
  , {parse_transform, lager_transform}
  ]
}.


%% -----------------------------------------------------------------------------
{deps, 
  [ {lager,         "3.9.2"}
  , {ranch,         "2.1.0"}
  , {cowboy,        "2.9.0"}
  , {gpb,           "4.19.1"}
  , {jsx,           "3.1.0"}
  , {crontab,       ".*", {git, "https://gitee.com/tercero/crontab.git",          {tag, "v1.1"}}}
  , {gamechat,      ".*", {git, "https://gitee.com/tercero/gamechat.git",         {tag, "v1.2"}}}
  , {metronome,     ".*", {git, "https://gitee.com/tercero/metronome.git",        {tag, "v1.0"}}}
  , {shield_words,  ".*", {git, "https://gitee.com/tercero/shield_words.git",     {tag, "v1.0.0"}}}
%%  mongodb 依赖，修复 poolboy 应对 otp 22
  , {poolboy,       ".*", {git, "https://github.com/hgxjune/poolboy.git",         {tag, "1.5.2.1"}}}
  , {bson,          ".*", {git, "https://github.com/comtihon/bson-erlang.git",    {tag, "v0.2.4"}}}
  , {pbkdf2,        ".*", {git, "https://github.com/comtihon/erlang-pbkdf2.git",  {tag, "2.0.1"}}}
  , {mongodb,       ".*", {git, "https://github.com/comtihon/mongodb-erlang.git", {tag, "v3.2.0"}}}
%%, {mongodb,       ".*", {git, "git://github.com/comtihon/mongodb-erlang",       {tag, "v3.2.0"}}}
  ]
}.

%% 解决 MongoDB 编译报 rebar_ct 找不到
{overrides, [ {override, mongodb, [ {plugins, []} ]} ]}.


%% -----------------------------------------------------------------------------
{shell, 
  [ {config, "./config/sys.config"}
  , {apps, [ catsvr ]}
  ]
}.


%% -----------------------------------------------------------------------------
%% protobuff 的插件
{plugins, [ { rebar3_gpb_plugin, "v2.21.0" } ] }.

%% rebar3_gpb_plugin 生成配置（使用 syntax = "proto3"; ）
{gpb_opts,
  [ {recursive, false}                  %% 是否递归 proto 文件目录
  , {i, "./../catproto/protobuf"}   %% proto 文件目录
  , {module_name_suffix, "_pb2"}        %% 默认输出文件后继
  , {o_erl, "./src/proto/pb2"}
  , {strings_as_binaries, false}        %% 字符串是列表
  , msgs_as_maps                        %% 消息以 map 方式来解析
% , mapfields_as_maps                   %% protobuf map 解析为 erlang map
% , defs_as_maps                        %% 内部解析过程使用 map，不使用 #field{}
% , {maps_unset_optional, omitted}      %% 消息以 record 解析时为 undefined，map 时为类型默认值
  , {verify, always}                    %% 对值进行检查
  ]
}.

%% rebar3 命令钩子
{ provider_hooks,
  [ { pre,
      [ {compile, {protobuf, compile}}
      , {clean, {protobuf, clean}}
      ]
    }
  ]
}.



